package fr.univ.lille1.server.manager;

import javax.ejb.Remote;

import fr.univ.lille1.server.domain.SessionKey;
import fr.univ.lille1.server.domain.User;
import fr.univ.lille1.server.domain.User.Type;

/**
 * @author TagThis
 * 
 * manage users
 *
 */
@Remote
public interface UserManager {
	
	/**
	 * create a user in the database
	 * @param name the user's name
	 * @param password the user's password
	 * @param mail the email address
	 * @return the session key for the created user
	 */
	SessionKey createUser(String name, String password, String mail,Type userType);
	
	/**
	 * update a user
	 * @param id the user's id
	 * @param name the user's name
	 * @param password the user's password
	 * @param mail the user's mail
	 * @return the user updated
	 */
	User updateUser(int id, String name, String password, String mail);
	
	/**
	 * get a user from its id
	 * @param id the user's id
	 * @return the user to find, if it does not exist the function return null
	 */
	User findUserById(int id);
	
	/**
	 * get the user from its name
	 * @param name the user's name
	 * @return the user to find, if it does not exist the function return null
	 */
	User findUserByName(String name);
	
	/**
	 * get a user from its address mail
	 * @param mail the user's address mail
	 * @return the user to find, if it does not exist the function return null
	 */
	User findUserByMail(String mail);
	
	/**
	 * allows to login to the application
	 * @param mail the user's address mail
	 * @param password the user's password
	 * @return true if the user is logged after he has entered its information, otherwise false
	 */
	boolean login(String mail, String password);

}
